Conversation
|
Thanks for the PR. Regarding this code, it seems that there is a misunderstanding. def compute_hardware_values(self, strengths: np.array) -> np.array:
raise PyAMLException("The identity model does not support computation")
def compute_strengths(self, currents: np.array) -> np.array:
raise PyAMLException("The identity model does not support computation")When working in hardware units, to work with a simulator, you need a conversion model so when using an identity model it is not possible to compute_strengths(). But when working in physic units, then access to the simulator is possible as no conversion is required. I do not see the point of the |
|
Thanks @JeanLucPons for the review. The simulator access is indeed handled via the get/set methods. The compute methods are only intended to delegate to a conversion model when one exists, which is not the case for an identity model. |
|
The |
Not only. The compute_strengths() is used if you want to use aggregator.
This is just a matter to implement correctly compute_hardware_values() and compute_strengths() in function of defined fields. |
|
In the identity model, I expect that either a power supply or a magnet device (physics) is specified but not both. Mapping strengh: type: pyaml.magnet.quadrupole
name: QF1A-C01
model:
type: pyaml.magnet.identity_model
unit: 1/m
physics:
type: tango.pyaml.attribute
attribute: srmag/m-qf1/c05-a/strength# 2 following lines are equivalent
sr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").strength.set(0.000010)
sr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").hardware.set(0.000010)
# 2 following lines are equivalent
sr.live.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").strength.set(0.000010)
sr.live.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").hardware.set(0.000010)
print(sr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1E-C04").strength.unit()) # 1/m
print(sr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1E-C04").hardware.unit()) # 1/mMapping current (no access to simulator): type: pyaml.magnet.quadrupole
name: QF1A-C01
model:
type: pyaml.magnet.identity_model
unit: A
powerconverter:
type: tango.pyaml.attribute
attribute: srmag/vps-qf1/c05-a/currentsr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").strength.set(0.000010) # throw an exception
sr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").hardware.set(82) # throw an exception
sr.live.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").strength.set(0.000010) # throw an exception
sr.live.get_magnet(MagnetType.QUADRUPOLE,"QF1A-C01").hardware.set(82) # Write 82A
print(sr.design.get_magnet(MagnetType.QUADRUPOLE,"QF1E-C04").strength.unit()) # throw an exception
print(sr.live.get_magnet(MagnetType.QUADRUPOLE,"QF1E-C04").hardware.unit()) # A |
|
I'll turn your example into a test. |
|
@JeanLucPons, I'm coming back to you about the identity_cfm_model. It is actually necessary to address the element in the design, as there will be only one thick element in the lattice. sr.live.get_magnets(MagnetType.HCorrector)`Note that this last point should be addressed in a new issue if a change is needed. |
|
I'm not sure to fully understand. For an arrays, the type is defined in the config file. arrays:
- type: pyaml.arrays.hcorrector
name: HCORR
elements:
- SD1A-C01-H
- SD1A-C02-H
- type: pyaml.arrays.sextupole
name: SEXT
elements:
- SD1A-C01-S
- SD1A-C02-S
devices:
type: pyaml.magnet.cfm_magnet
name: SD1A-C01 #Name of the element in the lattice
mapping:
- [B0, SD1A-C01-H]
- [A0, SD1A-C01-V]
- [B2, SD1A-C01-S]
model:
...
type: pyaml.magnet.cfm_magnet
name: SD1A-C02 #Name of the element in the lattice
mapping:
- [B0, SD1A-C02-H]
- [A0, SD1A-C02-V]
- [B2, SD1A-C02-S]
model:
... sr.design.get_magnets("HCORR").strengths.set([0.000010,-0.000008])
sr.design.get_magnets("SEXT").strengths.set([-14.103,-14.107])If you want to use an identity model, it means that either: arrays:
- type: pyaml.arrays.hcorrector
name: HCORR
elements:
- SD1A-C01
- SD1A-C02
- type: pyaml.arrays.sextupole
name: SEXT
elements:
- SD1A-C01
- SD1A-C02
devices:
type: pyaml.magnet.hcorrector
name: SD1A-C01 #Name of the element in the lattice
model:
type: pyaml.magnet.identity_model
physics:
type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c01-a/h_strength
type: pyaml.magnet.sextupole
name: SD1A-C01 #Name of the element in the lattice
model:
type: pyaml.magnet.identity_model
physics:
type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c01-a/strength
type: pyaml.magnet.hcorrector
name: SD1A-C02 #Name of the element in the lattice
model:
type: pyaml.magnet.identity_model
physics:
type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c02-a/h_strength
type: pyaml.magnet.sextupole
name: SD1A-C02 #Name of the element in the lattice
model:
type: pyaml.magnet.identity_model
physics:
type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c02-a/strengthImportant: In the config file the element name is not unique. It is the couple type,name (i.e. HCorrector,SD1A-C01) which is unique. |
|
@JeanLucPons, ok the file will be a bit long, but that's fine. |
|
In order to reduce the number of line, you can implement an devices:
type: pyaml.magnet.cfm_magnet
name: SD1A-C01 #Name of the element in the lattice
mapping:
- [B0, SD1A-C01-H]
- [A0, SD1A-C01-V]
- [B2, SD1A-C01-S]
model:
type: pyaml.magnet.identity_cfm_model
physics:
- type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c01-a/h_strength
- type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c01-a/v_strength
- type: tango.pyaml.attribute
attribute: srmag/m-sd1a/c01-a/strength |
|
@JeanLucPons your last proposal (with a cfm_magnet) seems clearer to me, but I’ll create another issue for that so others can discuss it. Moreover, at SOLEIL, some correctors will be driven by a kick angle, which will imply further changes if i'm correct. |
|
To be coherent, the strength of a dipole should be without unit. |
|
I’ll create the corresponding issues.
|
|
@JeanLucPons it's fine to work with PolynomA/B[0] for correctors. I'll make the change in our test lattice but we might want to support this feature in the future as it is a AT/pyAT feature. |
Implementation of an identity model to access to hardware and/or physics values in the control system.